﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KVB.Common;
using Customer_Profile.eCard.DBDao;
using Customer_Profile.Admin;
namespace Customer_Profile.eCard.Settle
{
    public partial class Settle_transfer_list : System.Web.UI.Page
    {
        string strUserName = "";
        string strUserID = "";
        string strEntity = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            Comm.CheckSession(this.Page, "/login.aspx", "usermodel");
            if (Session["usermodel"] != null)
            {
                strUserID = ((UserInfoEntity)Session["usermodel"]).UserLoginId;
                strUserName = ((UserInfoEntity)Session["usermodel"]).UserName;
                strEntity = ((UserInfoEntity)Session["usermodel"]).UserOffice;
            }
            else
            {
                Log.WriteDefaultLog("main_01 Page_Load", "Session is null");
                return;
            }
            string strURL = HttpContext.Current.Request.Url.AbsolutePath;
            bool bok = Comm.ifhasright(strUserID, strURL);
            if (!bok)
            {
                Response.Write("你无权访问此页面");
                Response.End();
            }

            if (!Page.IsPostBack)
            {               
                Comm.BindDll(ref dropTransferStatus, "SettleTransferStatus", false, "");
                //dropIfreward.Items.RemoveAt(0);

                txtcreatedatebegin.Text = DateTime.Now.ToString("yyyy-MM") + "-01";
                //string strYear = txtcreatedatebegin.Text.Substring(0, 4);
                //string strMonth = txtcreatedatebegin.Text.Substring(5, 2);
                txtcreatedateend.Text = DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy-MM-01")).AddDays(-1).ToString("yyyy-MM-dd");
                //dropYear.Items.FindByValue(strYear).Selected = true;
                //dropMonth.Items.FindByValue(strMonth).Selected = true;
            }
            bindGrid();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {

        }

        private void bindGrid()
        {
            string strTitle = txtTitle.Text.Trim();
            string strStatus = dropTransferStatus.SelectedItem.Value;
            string strStartDate = txtcreatedatebegin.Text.Trim();
            string strEndDate = txtcreatedateend.Text.Trim();

            if (strStartDate.Equals("") || strEndDate.Equals(""))
            {
                Response.Write("起始时间和结束时间不能为空");
            }

            DataSet ds = DealDao.SettleTransferList(strTitle, strStatus, strStartDate, strEndDate);
            gridReward.DataSource = ds;
            gridReward.DataBind();
        }
    }
}